package com.atelier.plugin.projectWizard.util;

import com.intellij.openapi.util.IconLoader;
import com.intellij.ui.RowIcon;
import gnu.trove.THashMap;

import javax.swing.*;
import java.util.Map;

/**
 * @author tangrufei
 * @date 2023-05-26 17:23
 */
public class ICONS{
        private static final Map<String, Icon> REGISTERED_ICONS = new THashMap<String, Icon>();
        public static final Icon HwayLogo = load("/icons/hywayLogo.png");
        public static final Icon SpringBoot = load("/icons/springBoot.png");
        public static final Icon DATA_EDITOR_INSERT_RECORD = load("/img/action/InsertRecord.png");
        public static final Icon Pom = load("/icons/mavenProject.svg");

        public static final Icon Mapper = load("/icons/xml.svg");
        public static final Icon ACTION_ADD = load("addConnection","/icons/action/add.png");
        public static final Icon REMOVE = load("remove","/icons/remove.svg");
        public static final Icon RedDuck = load("/icons/redDuck.svg");
        public static final Icon YellowDuck = load("/icons/yellowDuck.svg");

        public static final Icon JAVAFILE = load("/icons/java.svg");

        public static final Icon DataBase = load("/icons/myDatabase.svg");
        public static final Icon MYSQL = load("MYSQL","/icons/sql/mysql.svg");

        public static final Icon ORACLE = load("ORACLE","/icons/sql/oracle.svg");

        public static final Icon IDEA = load("IDEA","/icons/idea.svg");
        private static Icon load(String path) {
                return IconLoader.getIcon(path);
        }

        private static Icon load(String key, String path) {
                Icon icon = load(path);
                REGISTERED_ICONS.put(key, icon);
                return icon;
        }

        public static Icon getIcon(String key) {
                return REGISTERED_ICONS.get(key);
        }

        private static Icon createRowIcon(Icon left, Icon right) {
                RowIcon rowIcon = new RowIcon(2);
                rowIcon.setIcon(left, 0);
                rowIcon.setIcon(right, 1);
                return rowIcon;
        }
}
